﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SharedGenomics.Core;

namespace SharedGenomics.Domain
{
    public class Snp
    {
        private string _name;
        private short _chromosome;

        private Snp(short chromosome, long position)
        {
            this.Chromosome = chromosome;
            this.Position = position;
        }

        public Snp(string name, int rsNumber, short chromosome, long position)
            : this(chromosome, position)
        {
            this.RsNumber = rsNumber;
            this.Name = name;
        }

        public Snp(string name, short chromosome, long position)
            : this(chromosome, position)
        {
            this.Name = name;
        }

        public Snp(int rsNumber, short chromosome, long position)
            : this(chromosome, position)
        {
            this.RsNumber = rsNumber;
            this.Name = String.Format("Rs{0}", rsNumber);
        }

        public string Name
        {
            get { return this._name; }
            set
            {
                value.ThrowIfNull("Name");
                ExceptionHelper.ThrowIf<ArgumentException>(value.IsEmptyOrWhitespace(), "Name cannot be empty");

                this._name = value;
            }
        }

        public int? RsNumber { get; set; }

        public short Chromosome
        {
            get { return this._chromosome; }
            set
            {
                ExceptionHelper.ThrowIf<ArgumentException>(!SharedGenomics.Domain.Chromosome.IsValid(value), String.Format("{0} is not a valid chromosome", value));
                this._chromosome = value;
            }
        }

        public long Position { get; set; }
    }
}
